﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

// 
#pragma once
#include "GcmpActionInterface.h"
#include "IObject.h"
#include <vector>
#include <string>
#include <functional>
#include "GcmpApiDeclaration.h"

namespace gcmp
{
    class ICoordinateInputDefinition;

    /// \brief 坐标输入对话框接口类
    ///
    /// 用户可通过此对话框输入输出action执行过程需要的坐标点.
    /// 对话框由用户负责创建、销毁(如PickPointAction).    
    class GCMP_ACTION_INTERFACE_EXPORT IActionCoordinateInputWidget : public IObject
    {
    public:
        /// \brief 析构函数
        virtual ~IActionCoordinateInputWidget();

    public:
        typedef std::function<bool(const std::wstring &value, double &coordinate, std::wstring &errorTooltip)> CoordinateInputEditCallback;
        
        /// \brief 通过坐标输入框控件定义的方式创建对话框
        ///
        /// \param title对话框标题
        /// \param controlDefinitions 坐标输入框控件定义数组
        /// \param editCallback 编辑框完成输入回调，可以修改原始输入值
        /// \param isUserCustomInput 是否允许自定义输入(自定义字符代表坐标值)
        /// \return 坐标输入对话框
       static WeakPtr<IActionCoordinateInputWidget> Create(const std::wstring& title,
            std::vector<OwnerPtr<ICoordinateInputDefinition>>&& controlDefinitions,
            CoordinateInputEditCallback editCallback = nullptr, bool isUserCustomInput = false);
        
        /// \brief 刷新坐标输入对话框
        /// \return
        virtual void Refresh() = 0;    

        /// \brief 显示坐标输入对话框
        /// \return
        virtual void Show() = 0;

        /// \brief 隐藏坐标输入对话框
        /// \return 
        virtual void Hide() = 0;

        /// \brief 清理并隐藏坐标输入对话框
        /// \return
        virtual void HideAndClear() = 0;

        /// \brief 是否处于用户输入状态
        /// \return 用户输入状态返回true，否则false
        virtual bool IsInInputState() const = 0; 

        /// \brief 返回用户自定义输入标记
        /// \return 返回true表示用户自定义输入系统不检查输入合法性，默认值false
        virtual bool IsUserCustomInput() const = 0;
    };
}
